<?php
session_start();
require('fpdf.php');
//require_once('LeaveFormView.php');
class SimpleTable extends FPDF
{

    public function generateLeaveTable($width, $leaveNum, $DateOfFiling, $LeaveType, $Day, $startDate, $endDate, $Status, $Earn, $VLBal, $SLBal, $leaveTotal)

    {
		$count = count($leaveNum)-1;
		for($i=0;$i<$count;$i++)
		{
			$this->cell($width*0.08,5,$leaveNum[$i],1,0,"C");	//leavenum
			$this->cell($width*0.10,5,$DateOfFiling[$i],1,0,"C");	//date of filing
			$this->SetFont('Arial','B',5);
			$this->cell($width*0.10,5,$LeaveType[$i],1,0,"C");	//leave type
			$this->SetFont('Arial','B',8);
			$this->cell($width*0.05,5,$Day[$i],1,0,"C");	//days
			$this->cell($width*0.10,5,$startDate[$i],1,0,"C");	//start date
			$this->cell($width*0.10,5,$endDate[$i],1,0,"C");	//end date
			$this->cell($width*0.13,5,$Status[$i],1,0,"C");	//status
			$char = strpos($Earn[$i], ".");
			$Earn[$i] = substr($Earn[$i], 0, $char+4);
			$this->cell($width*0.06,5,$Earn[$i],1,0,"C");	//VL Earn	
			$this->cell($width*0.06,5,$Earn[$i],1,0,"C");	//SL Earn
			$char = strpos($VLBal[$i], ".");
			$VLBal[$i] = substr($VLBal[$i], 0, $char+4);
			$this->cell($width*0.06,5,$VLBal[$i],1,0,"C");	//VL Bal
			$char = strpos($SLBal[$i], ".");
			$SLBal[$i] = substr($SLBal[$i], 0, $char+4);
			$this->cell($width*0.06,5,$SLBal[$i],1,0,"C");	//SL Bal
			$char = strpos($leaveTotal[$i], ".");
			$leaveTotal[$i] = substr($leaveTotal[$i], 0, $char+4);
			$this->cell($width*0.10,5,$leaveTotal[$i],1,1,"C");	//leave total
		}
    }

}
 
	ob_clean();
	$pdf=new SimpleTable();
	$width = 184.65800;
	$LineStart = 12.7;
	$LineEnd = 197.35800;

	$pdf->AddPage();
	
	$fname = $_SESSION['fName'];
	$lname = $_SESSION['lName'];
	$mname = $_SESSION['mName'];
	$gender = $_SESSION['gender'];
	$gender = substr($gender,0,1);
	$dept = $_SESSION['dept'];
	$sickDays = $_SESSION['accumulatedSickDays'];
	$vacationDays = $_SESSION['accumulatedVacDays'];
	$specialDays = $_SESSION['accumulatedSpecial'];
	$paternalDays = $_SESSION['accumulatedPaternal'];
	$maternalDays = $_SESSION['accumulatedMaternal'];
	$reEnergizingDays = $_SESSION['accumulatedReEnergizing'];
	$monetDays = $_SESSION['accumulatedMonetization'];
	$vacwoDays = $_SESSION['accumulatedVacWo'];
	$sicwoDays = $_SESSION['accumulatedSicWo'];
	$forcedDays = $_SESSION['accumulatedForced'];
	$undertimeDays = $_SESSION['accumulatedUndertime'];
	$tardyDays = $_SESSION['accumulatedTardiness'];
	$excessSpecialDays = $_SESSION['accumulatedExcessSpecial'];
	$leaveNumber = $_SESSION['leaveNumber'];
	$leaveNum = array();
	$leaveNum = explode('/', $leaveNumber);
	$dateOfFiling = $_SESSION['dateOfFiling'];
	$DateOfFiling = array();
	$DateOfFiling = explode('/', $dateOfFiling);
	$leaveType = $_SESSION['leaveType'];
	$LeaveType = array();
	$LeaveType = explode('/', $leaveType);
	$day = $_SESSION['day'];
	$Day = array();
	$Day = explode('/', $day);
	$startdate = $_SESSION['startdate'];
	$startDate = array();
	$startDate = explode('/', $startdate);
	$enddate = $_SESSION['enddate'];
	$endDate = array();
	$endDate = explode('/', $enddate);
	$status = $_SESSION['status'];
	$Status = array();
	$Status = explode('/', $status);
	$earn = $_SESSION['earn'];
	$Earn = array();
	$Earn = explode('/', $earn);
	$VLbal = $_SESSION['VLbal'];
	$VLBal = array();
	$VLBal = explode('/', $VLbal);
	$SLbal = $_SESSION['SLbal'];
	$SLBal = array();
	$SLBal = explode('/', $SLbal);
	$leavetotal = $_SESSION['leavetotal'];
	$leaveTotal = array();
	$leaveTotal = explode('/', $leavetotal);
	
	//LeaveReport Table

	//---start of name
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(45,5,$lname,1,0,"C");
	$pdf->SetX(58.7);
	$pdf->cell(55,5,$fname,1,0,"C");
	$pdf->SetX(114.7);
	$pdf->cell(25,5,$mname,1,0,"C");
	$pdf->SetX(140.7);
	$pdf->cell(15,5," ",1,0,"C");
	$pdf->SetX($LineEnd-25);
	$pdf->cell(25,5," ",1,1,"C");
	$pdf->SetFont('Arial','I',8);
	$pdf->cell(45,5,"Last",0,0,"C");
	$pdf->SetX(58.7);
	$pdf->cell(55,5,"First",0,0,"C");
	$pdf->SetX(114.7);
	$pdf->cell(25,5,"Middle",0,0,"C");
	$pdf->SetX(140.7);
	$pdf->cell(15,5,"Suffix",0,0,"C");
	$pdf->SetX($LineEnd-25);
	$pdf->cell(25,5,"HRDO Emp Num",0,1,"C");
	//---end of name

	$pdf->SetLineWidth(0.5);
	$pdf->Line(156.7,25.4,156.7,36.4);
	$pdf->Line($LineStart,36.4,$LineEnd,36.4);
	$pdf->SetLineWidth(0);

	//---second
	$pdf->SetY(38);
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(8,5,$gender,1,0,"C");
	$pdf->SetX(21.7);
	$pdf->cell(12,5," ",1,0,"C");
	$pdf->SetX(34.7);
	$pdf->cell(18,5," ",1,0,"C");
	$pdf->SetX(53.7);
	$pdf->cell(65,5," ",1,0,"C");
	$pdf->SetX(122.7);
	$pdf->cell(28,5," ",1,0,"C");
	$pdf->SetX($LineEnd-45);
	$pdf->cell(45,5," ",1,1,"C");
	$pdf->SetFont('Arial','I',8);
	$pdf->cell(8,5,"Sex",0,0,"C");
	$pdf->SetX(21.7);
	$pdf->cell(12,5,"Civ Stat",0,0,"C");
	$pdf->SetX(34.7);
	$pdf->cell(18,5,"Bday",0,0,"C");
	$pdf->SetX(53.7);
	$pdf->cell(65,5,"Place of Birth",0,0,"C");
	$pdf->SetX(122.7);
	$pdf->cell(28,5,"Class",0,0,"C");
	$pdf->SetX($LineEnd-45);
	$pdf->cell(45,5,"Cummulative Leave Date",0,1,"C");
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(30,5," ",1,0,"C");
	$pdf->SetX(43.7);
	$pdf->cell(75,5," ",1,0,"C");
	$pdf->SetX(122.7);
	$pdf->cell(28,5," ",1,0,"C");
	$pdf->SetX($LineEnd-45);
	$pdf->cell(45,5," ",1,1,"C");
	$pdf->SetFont('Arial','I',8);
	$pdf->cell(20,5,"Eligibility",0,0,"C");
	$pdf->SetX(43.7);
	$pdf->cell(75,5,"Eligibility Score",0,0,"C");
	$pdf->SetX(122.7);
	$pdf->cell(28,5,"Status",0,0,"C");
	$pdf->SetX($LineEnd-45);
	$pdf->cell(45,5,"System Time and Date of Printing",0,1,"C");
	//---end second

	$pdf->SetLineWidth(0.5);
	$pdf->Line(120.8,36.4,120.7,59);
	$pdf->Line($LineStart,59,$LineEnd,59);
	$pdf->SetLineWidth(0);

	//--start third
	$pdf->SetY(61);
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(111,5," ",1,0,"C");
	$pdf->SetX(124.7);
	$pdf->cell(10,5," ",1,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(10,5," ",1,0,"C");
	$pdf->SetX(146.7);
	$pdf->cell(10,5," ",1,0,"C");
	$pdf->SetX(157.7);
	$pdf->cell(10,5," ",1,0,"C");
	$pdf->SetX($LineEnd-28);
	$pdf->cell(28,5," ",1,1,"C");
	$pdf->SetFont('Arial','I',8);
	$pdf->cell(111,5,"Designation",0,0,"C");
	$pdf->SetX(124.7);
	$pdf->cell(10,5,"Rank",0,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(10,5,"Level",0,0,"C");
	$pdf->SetX(146.7);
	$pdf->cell(10,5,"Grade",0,0,"C");
	$pdf->SetX(157.7);
	$pdf->cell(10,5,"Step",0,0,"C");
	$pdf->SetX($LineEnd-28);
	$pdf->cell(28,5,"Monthly Salary",0,1,"C");
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(91,5,$dept,1,0,"C");
	$pdf->SetX($LineEnd-93);
	$pdf->cell(93,5," ",1,1,"C");
	$pdf->SetFont('Arial','I',8);
	$pdf->cell(91,5,"Department",0,0,"C");
	$pdf->SetX($LineEnd-93);
	$pdf->cell(93,5,"Unit",0,1,"C");
	//--end third

	$pdf->SetLineWidth(0.5);
	$pdf->Line($LineStart,82,$LineEnd,82);
	$pdf->SetLineWidth(0);

	//--fourth
	$pdf->SetY(84);
	$pdf->SetFont('Arial','B',8);
	$pdf->cell(66,5,"VL Earned from other agency/company",1,0,"C");
	$pdf->SetX(79.7);
	$pdf->cell(27,5,"0.000",1,0,"C");
	$pdf->SetX(108.9);
	$pdf->cell(66,5,"SL Earned from other agency/company",1,0,"C");
	$pdf->SetX($LineEnd-21);
	$pdf->cell(21,5,"0.000",1,1,"C");
	$pdf->SetY(90);
	$pdf->cell(14,5,"VL From",1,0,"C");
	$pdf->cell(10,5,"2009",1,0,"C");
	$pdf->SetX(79.7);
	$pdf->cell(27,5,"96.250",1,0,"C");
	$pdf->SetX(108.9);
	$pdf->cell(14,5,"SL From",1,0,"C");
	$pdf->cell(10,5,"2009",1,0,"C");
	$pdf->SetX($LineEnd-21);
	$pdf->cell(21,5,"102.750",1,0,"C");
	$pdf->SetY(96);
	$pdf->cell(24,5,"VL Earned From",1,0,"C");
	$pdf->cell(18,5,"1-1-2008",1,0,"C");
	$pdf->cell(6,5,"To",1,0,"C");
	$pdf->cell(18,5,"1/1/2010",1,0,"C");
	$pdf->SetX(79.7);
	$pdf->SetX(108.9);
	$pdf->cell(24,5,"SL Earned From",1,0,"C");
	$pdf->cell(18,5,"1-1-2008",1,0,"C");
	$pdf->cell(6,5,"To",1,0,"C");
	$pdf->cell(18,5,"1/1/2010",1,0,"C");
	$pdf->SetX($LineEnd-21);
	$pdf->cell(21,5,"15.000",1,0,"C");
	//--end fourth

	$pdf->SetLineWidth(0.5);
	$pdf->Line(107.95,82,107.95,103);
	$pdf->Line($LineStart,103,$LineEnd,103);
	$pdf->SetLineWidth(0);

	//--fifth
	$pdf->SetY(105);
	$pdf->cell(29,5,"Vacation Leave",1,0,"C");
	$pdf->SetX(42.7);
	$pdf->cell(29,5,$vacationDays,1,0,"C");
	$pdf->SetX(72.7);
	$pdf->cell(29,5,"Tardiness",1,0,"C");
	$pdf->SetX(102.7);
	$pdf->cell(32,5,$tardyDays,1,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(29,5,"Special Leave",1,0,"C");
	$pdf->SetX($LineEnd-32);
	$pdf->cell(32,5,$specialDays,1,0,"C");
	$pdf->SetY(111);
	$pdf->cell(29,5,"Sick Leave",1,0,"C");
	$pdf->SetX(42.7);
	$pdf->cell(29,5,$sickDays,1,0,"C");
	$pdf->SetX(72.7);
	$pdf->cell(29,5,"Undertime",1,0,"C");
	$pdf->SetX(102.7);
	$pdf->cell(32,5,$undertimeDays,1,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(29,5,"Excess Spec Leave",1,0,"C");
	$pdf->SetX($LineEnd-32);
	$pdf->cell(32,5,$excessSpecialDays,1,0,"C");
	$pdf->SetY(117);
	$pdf->cell(29,5,"Forced Leave",1,0,"C");
	$pdf->SetX(42.7);
	$pdf->cell(29,5,$forcedDays,1,0,"C");
	$pdf->SetX(72.7);
	$pdf->cell(8,5,"Mat",1,0,"C");
	$pdf->SetX(81.7);
	$pdf->cell(23,5,$maternalDays,1,0,"C");
	$pdf->SetX(105.7);
	$pdf->cell(8,5,"Pat",1,0,"C");
	$pdf->SetX(114.7);
	$pdf->cell(20,5,$paternalDays,1,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(29,5,"ReEnergizing Leave",1,0,"C");
	$pdf->SetX($LineEnd-32);
	$pdf->cell(32,5,$reEnergizingDays,1,0,"C");
	$pdf->SetY(123);
	$pdf->cell(29,5,"2007 Monetization",1,0,"C");
	$pdf->SetX(42.7);
	$pdf->cell(29,5,$monetDays,1,0,"C");
	$pdf->SetX(72.7);
	$pdf->cell(29,5,"VL Leave w/o Pay",1,0,"C");
	$pdf->SetX(102.7);
	$pdf->cell(32,5,$vacwoDays,1,0,"C");
	$pdf->SetX(135.7);
	$pdf->cell(29,5,"SL Leave w/o Pay",1,0,"C");
	$pdf->SetX($LineEnd-32);
	$pdf->cell(32,5,$sicwoDays,1,1,"C");
	//--end fifth

	$pdf->SetLineWidth(0.5);
	$pdf->Line($LineStart,130,$LineEnd,130);
	$pdf->SetLineWidth(0);

	//--LeaveReport
	$pdf->SetY(132);
	$pdf->cell($width*0.08,7,"VL as of",1,0);
	$pdf->cell($width*0.10,7," <date> ",1,0,"C");
	$pdf->SetX(47);
	$pdf->cell($width*0.10+$width*0.10+$width*0.05,7," <VL credit> ",1,0,"C");
	$pdf->SetX(117);
	$pdf->cell($width*0.08,7,"SL as of",1,0);
	$pdf->cell($width*0.10,7," <date> ",1,0,"C");
	$pdf->SetX($LineEnd-($width*0.10+$width*0.10+$width*0.05));
	$pdf->cell($width*0.10+$width*0.10+$width*0.05,7," <SL credit> ",1,0,"C");

	$pdf->SetY(140);
	$pdf->cell($width*0.08,5,"LeaveNo",1,0,"C");
	$pdf->cell($width*0.10,5,"DateOfFiling",1,0,"C");
	$pdf->cell($width*0.10,5,"LeaveType",1,0,"C");
	$pdf->cell($width*0.05,5,"Days",1,0,"C");
	$pdf->cell($width*0.10,5,"StartDate",1,0,"C");
	$pdf->cell($width*0.10,5,"EndDate",1,0,"C");
	$pdf->cell($width*0.13,5,"Status",1,0,"C");
	$pdf->cell($width*0.06,5,"VLEarn",1,0,"C");
	$pdf->cell($width*0.06,5,"SLEarn",1,0,"C");
	$pdf->cell($width*0.06,5,"VL Bal.",1,0,"C");
	$pdf->cell($width*0.06,5,"SL Bal.",1,0,"C");
	$pdf->cell($width*0.10,5,"Leave Total",1,1,"C");

	$pdf->generateLeaveTable($width, $leaveNum, $DateOfFiling, $LeaveType, $Day, $startDate, $endDate, $Status, $Earn, $VLBal, $SLBal, $leaveTotal);
	//--End LeaveReport


	$pdf->Output();

?>